extends layout2

block content
	style.
		.table-striped th , td{
			text-align:center;
		}
		.table-striped td .u_state {
			background: #dddddd;
			width: 20px;
			height: 20px;
			display: inline-block;
			border-radius: 20px;
			vertical-align: bottom;
		}
		.table-striped td .u_success{
			background: #54c56d;
		}
		.table-striped td .u_failed{
			background: #d22d25;
		}
		.table-striped td .u_resnone{
			background: #cab658;
		}
	script(src="/socket.io/socket.io.js")
	script.
		//console.log("testssss");
		$(function(){
			/*
			// socket.io 서버에 접속한다
			var socket = io("");

			// 서버로 자신의 정보를 전송한다.
			socket.emit("login", {
			// name: "ungmo2",
			name: makeRandomName(),
			userid: "ungmo2@gmail.com"
			});

			// 서버로부터의 메시지가 수신되면
			socket.on("login", function(data) {
			$("#chatLogs").append("<div><strong>" + data + "</strong> has joined</div>");
			});

			// 서버로부터의 메시지가 수신되면
			socket.on("chat", function(data) {
			$("#chatLogs").append("<div>" + data.msg + " : from <strong>" + data.from.name + "</strong></div>");
			});

			// Send 버튼이 클릭되면
			$("form").submit(function(e) {
			e.preventDefault();
			var $msgForm = $("#msgForm");

			// 서버로 메시지를 전송한다.
			socket.emit("chat", { msg: $msgForm.val() });
			$msgForm.val("");
			});

			function makeRandomName(){
			var name = "";
			var possible = "abcdefghijklmnopqrstuvwxyz";
			for( var i = 0; i < 3; i++ ) {
				name += possible.charAt(Math.floor(Math.random() * possible.length));
			}
			return name;
			}
			*/
		});

	include header
	.container-fluid
		.row
			include menu
			.col-sm-9.col-sm-offset-3.col-md-10.col-md-offset-2.main
				.row.placeholders					
				h2.sub-header 设备状态
				div
					-for(var i in totalfile)
						div(style="border:1px solid black; display:inline-block; margin:5px;")
							h5
								| #{totalfile[i].gateway.p_name}(#{totalfile[i].gateway.g_id})
							.table-responsive(style="clear:both;")
							table.table.table-striped(border="1")
								thead
									tr
									-for(var _i in totalfile[i].gateway)																								
										case _i
											when "p_code"
												th 产品代码
											when "m_name"
												th 型号名称
											when "k_version"
												th 内核版本
											when "b_number"
												th 版本号												
											when "f_version"
												th 固件版本
											when "f_date"
												th 日期
											when "u_state"
												th 固件更新状态
											when "k_version"
												th 内核版本
											when "g_id"
												th(style="display:none") #{_i}
											when "p_name"													
												th(style="display:none") #{_i}
											default
												th #{_i}																					
								tbody																
									tr
									-for(var _i in totalfile[i].gateway)
										case _i											
											when "g_id"												
												td(style="display:none") #{totalfile[i].gateway[_i]}
											when "p_name"					
												td(style="display:none") #{totalfile[i].gateway[_i]}
											when "u_state"
												case totalfile[i].gateway[_i]
													when 0
														td 更新成功
															span.u_state.u_success
													when 1
														td 更新失败
															span.u_state.u_failed
													when 2
														td 待更新
															span.u_state.u_wait
													when 3
														td 没有反应
															span.u_state.u_resnone
													default
														td ?
															span.u_state																				
											default
												td #{totalfile[i].gateway[_i]}